#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int lengthAfterTransformations(string s, int t) {
        using LL = long long;
        const int MOD = 1e9 + 7;
        vector<LL> prevCount(26, 0);
        for (auto& c : s)
        {
            prevCount[c - 'a']++;
        }
        for (int trans = 0; trans < t; trans++)
        {
            vector<LL> nextCount(26, 0);
            nextCount[0] = nextCount[1] = prevCount[25];
            for (int i = 0; i < 25; i++)
            {
                nextCount[i + 1] = (nextCount[i + 1] + prevCount[i]) % MOD;
            }
            prevCount = move(nextCount);
        }
        LL res = 0;
        for (int i = 0; i < 26; i++)
        {
            res = (res + prevCount[i]) % MOD;
        }
        return res;
    }
};